﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GN.Pay.Client.Request.Trade;
using GN.Pay.Client.Response.Trade;
using GN.Pay.Client.Utils;

namespace GN.Pay.Client.Services
{
    /// <summary>
    /// 客户端交易申请服务实现
    /// </summary>
    class TradeApplyService : APayService, ITradeApplyService
    {
        private const string PayApplyAndChannelRegister_Service = "trade.apply.pay.applychannel.register";
        private const string PayApplyRegister_Service = "trade.apply.pay.register";
        private const string PayChannelRegister_Service = "trade.apply.pay.channel.register";
        private const string RefundApply_Service = "trade.apply.refund.apply";
        private const string TransfersApply_Service = "trade.apply.transfers.apply";
        private const string SmsPay_Service = "trade.apply.pay.channel.smspay";
        

        public TradeApplyService(IServiceClient client) : base(client)
        {
        }

        /// <summary>
        /// 支付申请与通道注册
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public PayChannelResponse PayApplyAndChannelRegister(PayApplyAndChannelRequest request)
        {
            ExceptionUtils.CheckNotNull(request, nameof(request));
            return this.Client.CallService<PayApplyAndChannelRequest, PayChannelResponse>(PayApplyAndChannelRegister_Service, request);
        }

        /// <summary>
        /// 支付申请注册
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public PayApplyResponse PayApplyRegister(PayApplyRequest request)
        {
            ExceptionUtils.CheckNotNull(request, nameof(request));
            return this.Client.CallService<PayApplyRequest, PayApplyResponse>(PayApplyRegister_Service, request);
        }

        /// <summary>
        /// 支付通道注册
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public PayChannelResponse PayChannelRegister(PayChannelRequest request)
        {
            ExceptionUtils.CheckNotNull(request, nameof(request));
            return this.Client.CallService<PayChannelRequest, PayChannelResponse>(PayChannelRegister_Service, request);
        }

        /// <summary>
        /// 短信付款
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns></returns>
        public PayChannelResponse SmsPay(SmsPayRequest request)
        {
            ExceptionUtils.CheckNotNull(request, nameof(request));
            return this.Client.CallService<SmsPayRequest, PayChannelResponse>(SmsPay_Service, request);
        }

        /// <summary>
        /// 退款申请
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns></returns>
        public RefundApplyResponse RefundApply(RefundApplyRequest request)
        {
            ExceptionUtils.CheckNotNull(request, nameof(request));
            return this.Client.CallService<RefundApplyRequest,
                RefundApplyResponse>(RefundApply_Service,
                request);
        }        

        /// <summary>
        /// 转账申请
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns></returns>
        public TransfersApplyResponse TransfersApply(TransfersApplyRequest request)
        {
            ExceptionUtils.CheckNotNull(request, nameof(request));
            return this.Client.CallService<TransfersApplyRequest,
                TransfersApplyResponse>(TransfersApply_Service,
                request);
        }
       
    }
}
